package com.konsung.ksdc.common.widget;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;

import com.konsung.ksdc.R;

/**
 * 选择上传照片方式popupWindow
 * Created by Administrator on 2016/3/23 0023.
 */
public class TakePicBottomPop extends PopupWindow {
    private View mView;
    private Button btnSaveProject;
    private Button btnAbandonProject;
    private Button btnCancelProject;

    /**
     * 构造方法
     * @param context 上下文
     * @param itemsOnClick 点击监听
     */
    public TakePicBottomPop(Activity context, View.OnClickListener itemsOnClick) {
        super(context);

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context
                .LAYOUT_INFLATER_SERVICE);
        mView = inflater.inflate(R.layout.activity_popup, null);

        btnSaveProject = (Button) mView.findViewById(R.id.btn_take_photo);
        btnAbandonProject = (Button) mView.findViewById(R.id.btn_album);
        btnCancelProject = (Button) mView.findViewById(R.id.btn_cancel);

        // 设置按钮监听
        btnCancelProject.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        btnSaveProject.setOnClickListener(itemsOnClick);
        btnAbandonProject.setOnClickListener(itemsOnClick);

        //设置PopupWindow的View
        this.setContentView(mView);
        //设置PopupWindow弹出窗体的宽
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        //设置PopupWindow弹出窗体的高
        this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        //设置PopupWindow弹出窗体可点击
        this.setFocusable(true);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0x10000000);
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);
    }
}
